Popups.dll Tutorial
Written by [AFX]
Introduction:
Hello readers, and welcome to my small tutorial. In this tutorial, I will be covering the aspects of Popups.dll, which was created by DragonZap.
Incase you didn't know, Popups.dll allows the user to create popup menus with style. The DLL shouldn't be too hard for you to use.
Chapter 1: Setting up
In this chapter, we will go over the stuff we will need in order to create our popup menu. First, make sure Popups.dll is in your mIRC directory
(or wherever you want to put it). Let's assume that it is located as C:\mIRC\System\Dll\popups.dll. Also, we will need icons for this demonstration.
Make sure all icons are stored in C:\mIRC\icons (this is just for the example, you can put your icons anywhere, but make sure you correct your
aliases to match with the appropriate directories). So, we are now going to create a few aliases.
Here are the aliases provided. Type these in your remotes:
;this alias is for calling the DLL. It basically means: dll popups.dll command1 command2...
alias popdll { dll system\dll\popups.dll $$1- }
;this alias adds information to the popup we are going to create
alias additem_ { dll system\dll\popups.dll AddItem $1- }
;this alias returns us our icons directory
;usage: $ico(filename) DO NOT PUT THE ICON EXTENSION
;alias ico { return icons\ $+ $1- $+ .ico }
;this alias adds an icon to the popups' internal image list. just like setting icons with mdx controls.
alias loadimg_ { dll system\dll\popups.dll LoadImg $1- }
;this alias returns our directory where we are going to store our text files
alias txt { return $mircdir $+ \ $+ $1- $+ .txt }
;this alias displays the popup menu
alias pop1 tokenize 32 $dll(system\dll\popups.dll,Popup,$1-) | if ($isid) return $1- | $iif($4- != did not select a menu item,$4-)
Now that we got our aliases, we can proceed to the next step.
Chapter 2: Beginning our popup demonstration
In this section, we are going to start our demonstration popup. Before anything though, we need to create the "base" of our popup. We are going
to create our popup menu inside a new alias, so you can just type /popexample, and the popup will display:
alias popexample {
;creating our new popup menu. it is called "example", and has an icon size of 16 pixels by 16 pixels
popdll New example 16 16
Any popup we create using Popups.dll can have its' own style. Here are the available styles that Popups.dll has to offer (taken from Popups.dll readme):
bordericon | Icons in menus are given 3D borders instead of being highlighted. Alone, this makes the menu look like a Microsoft Office menu. |
bordertext | The text (or bitmap) of the menu items is given a border. Combined with "bordericon", this makes the menu look like an XFree86 menu. |
emboss | The icons (and bitmaps) of disabled menu items
are automatically drawn in an embossed style. You would avoid using this if you wanted to make disabled items show up your own way. |
reverse | Menu items with bitmaps are reversed when they are highlighted. |
For the demonstration, we are going to use the bordericon style. The output would end up like this:
;setting our popup to have a bordericon style
popdll SetStyle example bordericon
After this has been achieve, we can move on to the next step.
Chapter 3: Loading and adding information
We just finished setting up a new popup menu, with a bordericon style to it. Now, we need to start adding information to our popup. First, we are
going to load icons to our popup. Make sure all of the icons you wish to use for this popup are in the appropriate directory for the $ico alias, or else, this
will not work.
;loading the "query.ico" icon to our image list
loadimg_ example icon small $ico(query)
;loading the "server.ico" icon to our image list
loadimg_ example icon small $ico(server)
We now have the 2 icons "basic.ico" and "server.ico" loaded into our image list. Now, we want to display these icons in our popup menu. For our demonstration,
we are going to make a small server menu, so when you click on the servers available, you will connect to the server specified. Onwards:
;adding the icon "query.ico" to the popup menu
additem_ example end +CDd 1 1 Quick Servers
A breakdown on what we just did:
additem_ example: adding something to our menu (which is called example)
end: adds the item to the end of the list
+CDd: these are flags you can set when you add the popup item. This is taken from the Popups.dll readme:
Format: <menu> <pos> [+flags] [unsel#] [sel#] [trans] [text]{cr}[info]
> | Item has a submenu. [info] should be the name of the submenu. |
c | Item starts a new menu column, with no vertical separator |
C | Item starts a new menu column, with a vertical separator |
d | Item is disabled |
D | Item is the default selection (as a result, the text is made bold) |
x | The item is checked |
h | The item is highlighted (this is generally not set) |
r | The item is a radio item (the default checkmark is displayed as a dot instead of a check) |
b | The item does not have text, but instead has a bitmap. [text] is the filename of that bitmap. |
3 | If the 'b' flag is specified, these colors are mapped
to the 3D system colors: R G B 128 128 128 3D shadow color 192 192 192 3D face color 223 223 223 3D light color |
Now, my method of storing commands for a custom popup, is to store the information in a .txt file. How do we load all the information? Simple. We
are going to use a while loop.
;adding the icon "server.ico" to the popup menu and all servers listed in popservers.txt
var %l = 1
while (%l <= $lines($txt(popservers))) {
AddItem_ example end + 2 2 $gettok($read($txt(popservers),%l),1,%l) $cr $gettok($txt(popservers),3-,%l)
inc %l
}
Congratulations, you just added all the information to our popup, with the "server.ico" icon beside each server name. To add a server, open the
"popservers.txt" file. The format to add a server is:
Network_Name $cr server server_address
Example:
DALnet $cr server misc-e.dal.net
Chapter 4: A few more things, and conclusion
Well, we have loaded information, and added it to our popup. Now where is it? This is what the pop1 alias is for. It loads the menu at the $mouse.dx
$mouse.dy co-ordinates.
;displaying our popup menu
pop1 example $mouse.dx $mouse.dy
}
End
Result:
Where can you call a popup? Most scripters that I know that use Popups.dll often place popups in drop-down menus in their Toolbar. To do this, type the
following:
on *:dialog:dialog_name:dclick:id {
if ($did($dname,id).sel == id) { popexample }
}
In conclusion, Popups.dll isn't a very hard DLL to learn at all. A lot of people ask me for help with it, so I decided to write this tutorial about it. I hope that
you learned a little something from this, instead of just copying the code, and not reading the rest (yes, these people do exist, my control panel code got
ripped from a lot of users). If you are a new user to DLL's, ALWAYS consult it's help file first (I cannot stress this enough). All the answers to your questions
are in there. And as with this tutorial, also refer back to the readme that came with Popups.dll.
Information:
Nickname: [AFX], SoMeBoDy^SoMeOnE
Channels: #clan-x-scripterz
Networks: DALnet
Script: AFX v0.1b
Check out my ircnick.com profile
Check out my user info on mircscripts.org